"use strict";
cc._RF.push(module, 'b226f79ISpLqJCj2LiM3Qvy', 'UCSDK');
// scripts/UCSDK.js

"use strict";

var t = require;
var e = module;
var o = exports;

var _n27,
    i = void 0 && (void 0).__extends || (_n27 = function n(t, e) {
  return (_n27 = Object.setPrototypeOf || {
    __proto__: []
  } instanceof Array && function (t, e) {
    t.__proto__ = e;
  } || function (t, e) {
    for (var o in e) {
      Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
    }
  })(t, e);
}, function (t, e) {
  function o() {
    this.constructor = t;
  }

  _n27(t, e), t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o());
});

Object.defineProperty(o, "__esModule", {
  value: !0
});

var s = t("BaseSdk"),
    r = t("SDKEvent"),
    c = t("Common"),
    a = function (t) {
  function e() {
    var e = null !== t && t.apply(this, arguments) || this;
    return e._recorderShareFunc = null, e._musicPauseFunc = null, e._musicPauseThis = null, e._musicResumeFunc = null, e._musicResumeThis = null, e._clipboardData = "", e._playScreenTime = 0, e._screenSpaceTime = 0, e._interstitiaId = "", e._moreGameBtn = null, e._recorder = null, e._videoPath = "", e._recorderStatus = 0, e._recorderEndTime = 0, e._recorderTime = 0, e._groupId = "ballUsers", e._videoId = "6bcb8629b1h3s16cdm", e._bannerId = "bakof5ngp737nf5e92", e._screenId = "32j0xvji1d6e45gfqo", e._shareId = "7kfwckfor33pf7mmg8", e._shareTitle = "一起来粉碎球球吧", e._shareDesc = "粉碎球球", e._videoTopics = ["粉碎球球", "粉碎球球小游戏", "解压小游戏"], e._videoLoaded = !1, e._videoOptions = null, e._videoAd = null, e._interstitiaAd = null, e._bannerLoaded = !1, e.lastAdTime = 0, e.gridAd = null, e.banner = null, e.bannerCount = 0, e.screenShow = !1, e.lastshockTime = 0, e.accChangeBack = null, e;
  }

  return i(e, t), e.prototype.init = function () {
    this.lastAdTime = new Date().getTime();
    var t = cc.sys.BROWSER_TYPE_UC;
    cc.sys.BROWSER_TYPE_UC = "", setTimeout(function () {
      cc.sys.BROWSER_TYPE_UC = t;
    }, 100), uc.onLaunch(function (t) {
      console.log("uc.onLaunch success", JSON.stringify(t));
    }), this.loadBanner(!1);
  }, e.prototype.loadBanner = function (t) {
    void 0 === t && (t = !1);
  }, e.prototype.showBanner = function () {
    try {
      this.banner && this.banner.show();
    } catch (t) {}
  }, e.prototype.hideBanner = function () {
    try {
      this.banner && this.banner.hide();
    } catch (t) {}
  }, e.prototype.setKeepScreenOn = function (t) {
    uc.setKeepScreenOn(t);
  }, e.prototype.login = function (t) {
    var e = this;
    uc.login({
      force: t.force,
      success: function success(o) {
        console.log("login调用成功", o);
        var n = o.code,
            i = o.anonymousCode;
        if (o.isLogin) uc.getUserInfo({
          success: function success(o) {
            var i = JSON.stringify(o.userInfo),
                s = {
              code: n,
              json: i,
              visitor: !1
            };
            e.sendHttpRequest(c["default"].ttLoginUrl, s, function (e) {
              var o = e.data;
              0 == o.user.status ? (console.log("登录完成，准备回调"), t.success(o)) : (console.log("用户状态异常"), t.fail("你因违规操作,帐号已被系统冻结"));
            }, function (e) {
              console.log("request调用失败", e), t.fail("网络繁忙,请稍后再试");
            });
          },
          fail: function fail(o) {
            console.log("getUserInfo 调用失败", o);
            var n = {
              code: i,
              json: "{}",
              visitor: !0
            };
            e.sendHttpRequest(c["default"].ttLoginUrl, n, function (e) {
              var o = e.data;
              0 == o.user.status ? (console.log("登录完成，准备回调"), t.success(o)) : (console.log("用户状态异常"), t.fail("你因违规操作,帐号已被系统冻结"));
            }, function (e) {
              console.log("request调用失败", e), t.fail("网络繁忙,请稍后再试");
            });
          }
        });else {
          var s = {
            code: i,
            json: "{}",
            visitor: !0
          };
          e.sendHttpRequest(c["default"].ttLoginUrl, s, function (e) {
            var o = e.data;
            0 == o.user.status ? (console.log("登录完成，准备回调"), t.success(o)) : (console.log("用户状态异常"), t.fail("你因违规操作,帐号已被系统冻结"));
          }, function (e) {
            console.log("request调用失败", e), t.fail("网络繁忙,请稍后再试");
          });
        }
      },
      fail: function fail(e) {
        console.log("login调用失败", e), t.fail("登录失败,请稍后再试");
      }
    });
  }, e.prototype.getUserInfo = function (t) {
    t.success({
      nickName: "UC用户"
    }, "UC");
  }, e.prototype.createMoreGamesButton = function (t) {
    this._moreGameBtn || (console.log("创建更多游戏"), this._moreGameBtn = uc.createMoreGamesButton({
      type: "image",
      image: "images/moregame.png",
      style: {
        left: t.left,
        top: t.top,
        width: t.width,
        height: t.height,
        lineHeight: 49,
        backgroundColor: "#00000000",
        textColor: "#ffffff",
        textAlign: "center",
        fontSize: 16,
        borderRadius: 4,
        borderWidth: 1,
        borderColor: "#00000000"
      },
      appLaunchOptions: [],
      onNavigateToMiniGame: function onNavigateToMiniGame(t) {
        console.log("跳转其他小游戏", t);
      }
    }), this._moreGameBtn.onTap(function () {
      console.log("点击更多游戏");
    }));
  }, e.prototype.startRecorder = function () {
    this._recorder && !this._isRecorder && (this._recorderTime = new Date().getTime(), this._isRecorder = !0, this._recorder.start({
      duration: 300
    }), cc.systemEvent.emit(r["default"].CHANGE_RECORDER_STATE));
  }, e.prototype.stopRecorder = function (t) {
    this._recorder && this._isRecorder && (this._recorderEndTime = new Date().getTime(), this._recorderShareFunc = t, this._recorder.stop(), this._isRecorder = !1, cc.systemEvent.emit(r["default"].CHANGE_RECORDER_STATE));
  }, e.prototype.getIsScreenRecordVideo = function () {
    return "" != this._videoPath && this._recorderEndTime - this._recorderTime > 8e3;
  }, e.prototype.getRecorderState = function () {
    return this._isRecorder;
  }, e.prototype.getRecorderTime = function () {
    return this._recorderEndTime - this._recorderTime;
  }, e.prototype.getLastAdTime = function () {
    return this.lastAdTime;
  }, e.prototype.shareRecorder = function (t) {
    var e = this;

    if (this._videoPath && "" !== this._videoPath) {
      var o = t.query ? t.query : "";
      uc.shareAppMessage({
        channel: "video",
        title: e._shareTitle,
        desc: e._shareDesc,
        templateId: e._shareId,
        query: o,
        extra: {
          videoPath: e._videoPath,
          videoTopics: e._videoTopics,
          withVideoId: !0
        },
        success: function success(o) {
          t.success && t.success(o.videoId), e._videoPath = "", e.sendEvent({
            key: "shareVideoSuccess"
          }), console.log("分享视频成功");
        },
        fail: function fail(o) {
          console.log("分享视频失败", o), t.fail && t.fail(o), e.showToast("分享失败");
        },
        complete: function complete() {}
      }), e.sendEvent({
        key: "shareVideo"
      });
    } else this.showToast("正在生成录屏,请稍后!");
  }, e.prototype.showRewardVideo = function (t) {
    var e = this;
    e._videoOptions = t, e._videoAd ? this._videoAd.show().then(function () {
      console.log("显示广告成功");
    })["catch"](function (t) {
      console.log("显示广告错误", t), e._videoAd.load().then(function () {
        return e._videoAd.show();
      });
    }) : (this._videoAd = uc.createRewardVideoAd(), this._videoAd.onLoad(function () {
      console.log("广告加载完成");
    }), this._videoAd.onError(function (t) {
      e._videoLoaded = !1, e.sendEvent({
        key: "videoError",
        value: {
          code: t.errCode
        }
      }), setTimeout(function () {
        e._videoAd.load().then(function () {
          e._videoLoaded = !0;
        });
      }, 3e4), console.log("视频加载失败", t.errCode);
    }), this._videoAd.onClose(function (t) {
      e._videoLoaded = !1, e.lastAdTime = new Date().getTime(), t && t.isEnded ? (e._videoOptions && e._videoOptions.success && e._videoOptions.success(), e.sendEvent({
        key: "playVideoSuccess"
      })) : e.sendEvent({
        key: "playVideoFail"
      });
    }), this._videoAd.load().then(function () {
      e._videoLoaded = !0, e._videoAd.show().then(function () {
        console.log("显示广告成功");
      })["catch"](function (t) {
        console.log("显示广告错误", t), e._videoAd.load().then(function () {
          return e._videoAd.show();
        });
      });
    })), e.sendEvent({
      key: "playVideo"
    });
  }, e.prototype.setClipboardData = function (t) {
    uc.setClipboardData({
      data: t.data,
      success: function success() {
        t.success && t.success(), console.log("调用剪切板成功", t.data);
      },
      fail: function fail() {
        t.fail && t.fail(), console.log("调用剪切板失败", t.data);
      }
    });
  }, e.prototype.getVideoState = function () {
    return this._videoLoaded;
  }, e.prototype.playScreen = function (t) {
    void 0 === t && (t = 1), uc.getSystemInfoSync();
    var e = this;

    if (this.screenShow = !1, new Date().getTime() - this.lastAdTime > 6e4) {
      var o = uc.createInterstitialAd();
      o.onLoad(function () {
        console.log("插屏广告加载成功"), e.screenShow || (e.screenShow = !0, o.show().then()["catch"](function (t) {
          return console.log(t);
        }));
      }), o.load().then()["catch"](function (t) {
        return console.log(t);
      });
    }
  }, e.prototype.sendEvent = function () {}, e.prototype.vibrateShort = function () {
    var t = new Date().getTime();
    t - this.lastshockTime > 100 && c["default"]._shockOpen && (this.lastshockTime = t, uc.vibrateShort({
      success: function success() {},
      fail: function fail() {
        console.log("vibrateShort调用失败");
      }
    }));
  }, e.prototype.vibrateLong = function () {
    c["default"]._shockOpen && uc.vibrateLong({
      success: function success() {},
      fail: function fail() {
        console.log("vibrateLong调用失败");
      }
    });
  }, e.prototype.showToast = function (t) {
    uc.showToast({
      title: t,
      icon: "none",
      duration: 2e3,
      success: function success() {},
      fail: function fail() {}
    });
  }, e.prototype.share = function (t) {
    uc.shareAppMessage(t);
  }, e.prototype.setLocalStorage = function (t, e) {
    cc.sys.localStorage.setItem(t, e);
  }, e.prototype.getLocalStorage = function (t) {
    return cc.sys.localStorage.getItem(t);
  }, e.prototype.contentSafe = function (t) {
    var e = {
      text: t.content
    };
    this.sendHttpRequest(c["default"].contentSafeTT, e, function (e) {
      e.valid ? t.callBack(!0) : t.callBack(!1);
    }, function () {
      t.callBack(!1);
    });
  }, e.prototype.registerAccChange = function (t) {
    var e = this;
    this.accChangeBack = t, uc.startAccelerometer({
      success: function success(t) {
        console.log("调用开始加速度成功", t.errMsg);
      },
      fail: function fail(t) {
        console.log("调用开始加速度失败", t.errMsg);
      }
    }), uc.onAccelerometerChange(function (t) {
      e.accChangeBack(-t.y.toFixed(2), t.x.toFixed(2), t.z.toFixed(2), e);
    });
  }, e.prototype.unRegisterAccChange = function () {
    uc.stopAccelerometer({
      success: function success(t) {
        console.log("调用停止加速度成功", t.errMsg);
      },
      fail: function fail(t) {
        console.log("调用停止加速度失败", t.errMsg);
      }
    });
  }, e.prototype.onShow = function () {}, e.prototype.getLaunchOptionsSync = function () {
    return uc.getLaunchOptionsSync();
  }, e;
}(s["default"]);

o["default"] = a;

cc._RF.pop();